package work20250104;

/**
 * @author zdl
 * @date 2025/1/4
 */
public class Demo2 {
    public static void main(String[] args) {
        //2、编写一个程序，抛出空指针异常和除数为0异常。
        try{
            String s = null;
            System.out.println(s.length());
        }catch (NullPointerException e){
            System.out.println(e.getMessage());
        }
        try{
            System.out.println(1/0);
        }catch (ArithmeticException e){
            System.out.println(e.getMessage());
        }
    }
}
